package sk.mucha.tracking;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.Request;
import org.apache.wicket.Response;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.https.HttpsConfig;
import org.apache.wicket.protocol.https.HttpsRequestCycleProcessor;
import org.apache.wicket.request.IRequestCycleProcessor;
import org.apache.wicket.util.lang.PackageName;

import sk.mucha.tracking.classes.AuthStrategy;
import sk.mucha.tracking.classes.User;

/**
 * Application object for your web application. If you want to run this application without deploying, run the Start class.
 * 
 * @see sk.mucha.tracking.Start#main(String[])
 */
public class WicketApplication extends WebApplication
{    
	List<User> users;
	
    /**
     * Constructor
     */
	public WicketApplication()
	{
		this.users=new ArrayList<User>();
		generateUsers();
	}
	
	/**
	 * @see org.apache.wicket.Application#getHomePage()
	 */
	public Class<UserProfilePage> getHomePage()
	{
		return UserProfilePage.class;
	}

	@Override
	protected void init() {
		super.init();
		getSecuritySettings().setAuthorizationStrategy(new AuthStrategy());
		
		mount("/pages", PackageName.forPackage(UserProfilePage.class.getPackage()));
	}
	
	private void generateUsers() {
		users.add(new User("00001", "Laci", "Szalai", "lacis@gmail.com", "subaru"));
		users.add(new User("00002", "Peto", "Szato", "szato@gmail.com", "subaru"));
		users.add(new User("00003", "Peto", "Stancel", "stancel@gmail.com", "subaru"));
		users.add(new User("00004", "Patt", "Mjuca", "patt@gmail.com", "subaru"));
		users.add(new User("00005", "Romm", "Malik", "romm@gmail.com", "subaru"));
		users.add(new User("00006", "Laci1", "Szalai1", "lacis1@gmail.com", "subaru"));
		users.add(new User("00007", "Peto1", "Szato1", "szato1@gmail.com", "subaru"));
		users.add(new User("00008", "Peto1", "Stancel1", "stancel1@gmail.com", "subaru"));
		users.add(new User("00009", "Patt1", "Mjuca1", "patt1@gmail.com", "subaru"));
		users.add(new User("00010", "Romm1", "Malik1", "romm1@gmail.com", "subaru"));
		
		users.add(new User("00011", "Laci2", "Szalai2", "lacis2@gmail.com", "subaru"));
		users.add(new User("00012", "Peto2", "Szato2", "szato2@gmail.com", "subaru"));
		users.add(new User("00013", "Peto2", "Stancel2", "stancel2@gmail.com", "subaru"));
		users.add(new User("00014", "Patt2", "Mjuca2", "patt2@gmail.com", "subaru"));
		users.add(new User("00015", "Romm2", "Malik2", "romm2@gmail.com", "subaru"));
		users.add(new User("00016", "Laci12", "Szalai12", "lacis12@gmail.com", "subaru"));
		users.add(new User("00017", "Peto12", "Szato12", "szato12@gmail.com", "subaru"));
		users.add(new User("00018", "Peto12", "Stancel12", "stancel12@gmail.com", "subaru"));
		users.add(new User("00019", "Patt12", "Mjuca12", "patt12@gmail.com", "subaru"));
		users.add(new User("00020", "Romm12", "Malik12", "romm12@gmail.com", "subaru"));
	}
	
	public List<User> getUsers() {
		return users;
	}
	
	public Session newSession(Request request, Response response) {
		return new MySession(request);
	}
	
//	protected IRequestCycleProcessor newRequestCycleProcessor() {
//		return new HttpsRequestCycleProcessor(new HttpsConfig(8080, 8443));
//	}
}
